//
//  RecommendApp.m
//  upnpxdemo
//
//  Created by 赵帅 on 13-9-4.
//  Copyright (c) 2013年 wiimu.inc. All rights reserved.
//

#import "RecommendApp.h"

@implementation RecommendApp
@synthesize name;
@synthesize desc;
@synthesize url_iphone;
@synthesize url_ipad;
@synthesize image;

-(NSURL *)getAppstoreURL
{
    NSString * str = nil;
    if ([[UIDevice currentDevice] userInterfaceIdiom] == UIUserInterfaceIdiomPhone) {
        str = url_iphone;
    } else {
        str = url_ipad;
    }
    if(str == nil || [str length] == 0)
    {
        return nil;
    }
    
    return [NSURL URLWithString:str];
}

-(NSString *)getAppID
{
    NSString * str = nil;
    if ([[UIDevice currentDevice] userInterfaceIdiom] == UIUserInterfaceIdiomPhone) {
        str = url_iphone;
    } else {
        str = url_ipad;
    }
    
    NSRange beginRange = [str rangeOfString:@"/id" options:NSBackwardsSearch];
    NSRange endRange = [str rangeOfString:@"?" options:NSBackwardsSearch];

    NSString * idStr = [str substringWithRange:NSMakeRange(beginRange.location+3, (endRange.location-beginRange.location-3))];

    return  idStr;
}

@end
